//
//  VideoCollectionViewCell.m
//  BeanTrip
//
//  Created by houlei on 15/7/8.
//  Copyright (c) 2015年 PandaGroup. All rights reserved.
//

#import "VideoCollectionViewCell.h"
#import "UIImageView+WebCache.h"
#define WIDTH ([UIScreen mainScreen].bounds.size.width)
#define HEIGHT ([UIScreen mainScreen].bounds.size.height)

@implementation VideoCollectionViewCell

- (void)dealloc
{
    [_label release];
    [_imageV release];
    [_videoM release];
    [super dealloc];
}
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}
- (void)createSubViews
{
    //圆角
    self.layer.masksToBounds = YES;
    self.layer.cornerRadius = 8.0;
    self.layer.borderWidth = 1.0;
    self.layer.borderColor = [[UIColor blackColor] CGColor];
    //图片
    self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, WIDTH/3, WIDTH/3/16*9)];
    self.imageV.layer.masksToBounds = YES;
    self.imageV.layer.cornerRadius = 8.0;
    self.imageV.layer.borderWidth = 1.0;
    self.imageV.layer.borderColor = [[UIColor whiteColor] CGColor];
    [self.contentView addSubview:self.imageV];
    [_imageV release];
    //标题
    self.label = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH/3+10 , WIDTH/3/16*9/2-15, WIDTH/3*2-10, 30)];
    self.label.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.label];
    [_label release];
}
//重写set方法,赋值
- (void)setVideoM:(VideoModel *)videoM
{
    if (_videoM != videoM) {
        [_videoM release];
        _videoM = [videoM retain];
    }
    self.label.text = videoM.title;
    self.label.numberOfLines = 0;
    UIImage *image = [UIImage imageNamed:@"BeanTrip"];
    NSURL *url = [NSURL URLWithString:self.videoM.picUrl];
    [self.imageV sd_setImageWithURL:url placeholderImage:image];
}

@end
